package com.xayy.health.mgt.model;

import cn.kawins.mybatis.base.BaseModel;
import cn.kawins.mybatis.util.SnowflakeId;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.xayy.health.core.enums.TaskStatusEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import tk.mybatis.mapper.annotation.KeySql;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;

/**
 * 任务信息
 * @author houchengwei
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "HEALTH.tb_task_child_info")
@EqualsAndHashCode(callSuper = true)
public class TaskChildInfo extends BaseModel<Long> {

    @Id
    @Column(name = "id")
    @KeySql(genId = SnowflakeId.class)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    @ApiModelProperty(value = "任务id")
    @Column(name = "task_id")
    private Long taskId;

    @ApiModelProperty(value = "任务名称")
    @Column(name = "name")
    private String name;

    @ApiModelProperty(value = "卫星代号")
    @Column(name = "satellite_code")
    private String satelliteCode;

    @ApiModelProperty(value = "运行状态")
    @Column(name = "status")
    private Integer status;

    @ApiModelProperty(value = "图例名称")
    @Column(name = "legend_name")
    private String legendName;
    public void setStatus(Integer status) {
        this.status = status;
        this.setStatusName(TaskStatusEnum.valueof(status));
    }

    @Transient
    @ApiModelProperty(value = "运行状态")
    private String statusName;

    @ApiModelProperty(value = "参数")
    @Column(name = "params")
    private String params;

    @ApiModelProperty(value = "剔野方法")
    @Column(name = "ty_tag")
    private String tyTag;

    @ApiModelProperty(value = "填充方法")
    @Column(name = "tc_tag")
    private String tcTag;

    @ApiModelProperty(value = "平滑方法")
    @Column(name = "ph_tag")
    private String phTag;

    @Column(name = "model_name")
    @ApiModelProperty(value = "模型名称",notes = "在事后诊断和趋势预测的自动运行创建任务时候用到")
    private String modelName;

    @ApiModelProperty(value = "开始日期")
    @Column(name = "start_time")
    private Date startTime;

    @ApiModelProperty(value = "结束日期")
    @Column(name = "end_time")
    private Date endTime;

    @Column(name = "pred_number")
    @ApiModelProperty(value = "预测多少个点")
    private Integer predNumber;

    @Column(name = "time_span")
    @ApiModelProperty(value = "预测间隔")
    private Integer timeSpan;

    @Column(name = "error_num")
    @ApiModelProperty(value = "异常点数")
    private Integer errorNum;

    @ApiModelProperty(value = "是否多参数 1true是 0false否")
    @Column(name = "check_multiparameter")
    private Integer checkMultiparameter;

    @ApiModelProperty(value = "数据情况")
    @Column(name = "data_situation")
    private String dataSituation;

    @ApiModelProperty(value = "创建时间")
    @Column(name = "created_time")
    private Date createdTime;

    @ApiModelProperty(value = "是否是案例一", required = true)
    @Column(name = "is_case_one")
    private Integer isCaseOne;

    @ApiModelProperty(value = "算法是否存在异常情况 0否1是")
    @Column(name = "error_situation")
    private String errorSituation;

    @ApiModelProperty(value = "算法返回信息")
    @Column(name = "msg")
    private String msg;

    @ApiModelProperty(value = "图例id")
    private Long fileLogo;

    @Override
    public Long idValue() {
        return id;
    }

}
